package com.happyclub.pojo;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.sql.Time;
import java.util.Date;
import java.util.Objects;

/**
 * @author 高欢
 * @description TODO
 * @date 2019/4/4
 */
@Entity
@Table(name = "TB_ORDER", schema = "SCOTT")
@IdClass(TbOrderPK.class)
@EntityListeners(AuditingEntityListener.class)
public class TbOrder {
    private String id;
    private String userId;
    private String userName;
    private String address;
    private String telephone;
    private Date updateTime;
    private Date createTime;

    @Id
    @Column(name = "ID")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Id
    @Column(name = "USER_ID")
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "USER_NAME")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Basic
    @Column(name = "ADDRESS")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Basic
    @Column(name = "TELEPHONE")
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Basic
    @Column(name = "UPDATE_TIME")
    @LastModifiedDate
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    @CreatedDate
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbOrder tbOrder = (TbOrder) o;
        return Objects.equals(id, tbOrder.id) &&
                Objects.equals(userId, tbOrder.userId) &&
                Objects.equals(userName, tbOrder.userName) &&
                Objects.equals(address, tbOrder.address) &&
                Objects.equals(telephone, tbOrder.telephone) &&
                Objects.equals(updateTime, tbOrder.updateTime) &&
                Objects.equals(createTime, tbOrder.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userId, userName, address, telephone, updateTime, createTime);
    }
}
